<template>
  <div v-if="cityList.length">
    <!-- <Hot :hotCity="hotCity" />

    <Other :otherCity="otherCity" /> -->

    <Hot />

    <Other />
  </div>
  <div v-else>loading...</div>
</template>

<script>
// import { cityApi } from "@/api/city.js";
import Other from "./components/OtherCity.vue";
import Hot from "./components/HotCity.vue";

import { mapState, mapActions } from "vuex";

export default {
  computed: {
    // ...mapState(["cityList"]),
    ...mapState({
      cityList: (state) => state.city.cityList,
    }),
  },
  mounted() {
    this.asyncGetCity();
  },
  methods: {
    ...mapActions("city", ["asyncGetCity"]),
  },
  components: {
    Other,
    Hot,
  },
  // data() {
  //   return {
  //     cityList: [],
  //   };
  // },
  // computed: {
  //   hotCity() {
  //     return this.cityList[0];
  //   },
  //   otherCity() {
  //     return this.cityList.slice(1);
  //   },
  // },
  // mounted() {
  //   this.getCityData();
  // },
  // methods: {
  //   async getCityData() {
  //     const res = await cityApi();
  //     console.log(res);
  //     this.cityList = res.result;
  //   },
  // },
};
</script>

<style lang="less" scoped>
.item {
  height: 30px;
  line-height: 30px;
  padding-left: 25px;
  font-size: @m-font;
  background-color: #ddd;
}

.ul {
  display: flex;
  flex-wrap: wrap;
}

.hot-val {
  background: #fff;
  width: 29%;
  height: 0.66rem;
  margin: 15px 0;
  margin-left: 4%;
  padding: 0 0.08rem;
  border: 0.02rem solid #e6e6e6;
  border-radius: 0.06rem;
  line-height: 0.66rem;
  text-align: center;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: @m-font;
}

.val {
  height: 45px;
  padding-left: 15px;
  border-bottom: 1px solid @border-color;
  line-height: 45px;
  font-size: @m-font;
}
</style>
